package DataStructureAndAlgorithm.AcWing_每日一题.贪心题;
import java.util.Scanner;

//链接：https://www.acwing.com/problem/content/3767/
public class AcWing_3764 {
    //贪心策略
    //每次都把大的数加上尽量小的部分即可
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        for (int k = 0; k < t; k++){
            int n = in.nextInt();
            String str = in.next();
            String resA = "1";
            String resB = "1";
            for (int i = 1; i < n; i++){
                String big,small;
                if (str.charAt(i) == '1'){
                    big = "1";
                    small = "0";
                }else if (str.charAt(i) == '0'){
                    big = "0";
                    small = "0";

                }else {
                    if (resA.compareTo(resB) != 0){
                        big = "2";
                        small = "0";
                    }else {
                        big = "1";
                        small = "1";
                    }
                }

                if (resA.compareTo(resB) == 1){
                    resA = resA + small;
                    resB = resB + big;
                }else {
                    resA = resA + big;
                    resB = resB + small;
                }
            }
            System.out.println(resA);
            System.out.println(resB);
        }
    }
}
